import os

from agents import Agent, Runner
from dotenv import load_dotenv

from src.common_tools import getAgent, chat, query_weather, writeFile, python_inter, fig_inter, sql_inter, extract_data, \
    get_answer, get_answer_github, save_markdown_to_file

load_dotenv(override=True)

os.environ['HTTP_PROXY'] = 'http://127.0.0.1:10809'
os.environ['HTTPS_PROXY'] = 'http://127.0.0.1:10809'

chinese_agent = getAgent(
    agent_name="Chinese agent",
    instructions="你只能用中文进行回复。",
    tools=[])

english_agent = getAgent(
    agent_name="English agent",
    instructions="你只能用英文进行回复。",
    tools=[])

switch_agent = getAgent(
    agent_name="Switch agent",
    instructions="根据用户的输入，切换到对应的语言的agent。",
    tools=[],
    handoff=[])
async def test_one_agent():
    result = await Runner.run(chinese_agent,"你是谁？")
    print(result.final_output)
    print(result.to_input_list())

    print("#"*50)
    result = await Runner.run(english_agent, "你是谁？")
    print(result.final_output)
    print(result.to_input_list())

async def test_switch_agent():
    result = await Runner.run(switch_agent, "请用英文回答我，问题是：你是诠？")
    print(result.final_output)
    print(result.to_input_list())

if __name__ == "__main__":
    import asyncio
    #asyncio.run(test_one_agent())
    asyncio.run(test_switch_agent())